﻿<UserControl x:Class="Tareas.CollectionPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Loaded="Page_Loaded" Unloaded="Page_Unloaded"
    mc:Ignorable="d" 
    xmlns:local="using:Tareas"
    d:DesignHeight="768" d:DesignWidth="1366">

    <UserControl.Resources>
        <CollectionViewSource x:Name="CollectionViewSource" x:Key="CollectionViewSource" />
    </UserControl.Resources>

    <!-- Page Content -->

    <Grid x:Name="LayoutRoot" PointerPressed="LayoutRoot_PointerPressed" Style="{StaticResource LayoutRootGridStyle}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OrientationStates">
                <VisualState x:Name="Full"/>
                <VisualState x:Name="Fill"/>
                <VisualState x:Name="Portrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemListView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Style" Storyboard.TargetName="BackButton">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Style" Storyboard.TargetName="PageTitle">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapPageTitleStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="ItemTemplate" Storyboard.TargetName="ItemListView">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapListItemTemplate}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="ItemsPanel" Storyboard.TargetName="ItemListView">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnapListItemsPanelTemplate}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemGridView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemListView" Storyboard.TargetProperty="Visibility" >
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="PageTitle" Text="Proyectos" Style="{StaticResource PageTitleStyle}" Grid.Column="1" Grid.Row="0"/>
        </Grid>
        <TextBlock x:Name="Loading" Text="Cargando" Style="{StaticResource DefaultFontStyle}" Margin="120,0,0,0" Grid.Row="1" />
        <GridView x:Name="ItemGridView" ItemsSource="{Binding Source={StaticResource CollectionViewSource}}" ItemTemplate="{StaticResource GroupedItemTemplate}" ItemContainerStyle="{StaticResource GridTileStyle}" ItemsPanel="{StaticResource GridItemsPanelTemplate}"
              Grid.Row="2" Background="{StaticResource PageBackgroundBrush}" BorderThickness="0" VerticalAlignment="Stretch"
              SelectionChanged="ItemView_SelectionChanged" Margin="0"/>
        <ListView x:Name="ItemListView" ItemsSource="{Binding Source={StaticResource CollectionViewSource}}" ItemTemplate="{StaticResource PortraitListItemTemplate}" ItemContainerStyle="{StaticResource ListTileStyle}"  ItemsPanel="{StaticResource PortraitListItemsPanelTemplate}"
              Visibility="Collapsed" Grid.Row="2" Background="{StaticResource PageBackgroundBrush}" BorderThickness="0" VerticalAlignment="Stretch"
              SelectionChanged="ItemView_SelectionChanged"/>
        
            <ApplicationBar x:Name="AppBar" Grid.ColumnSpan="2" Grid.Row="3" VerticalAlignment="Bottom" IsPersistent="False"  
                    Height="Auto" DismissMode="EdgeSwipe" HorizontalAlignment="Stretch" Background="#548D8D8D">
                <ApplicationBar.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="FontFamily" Value="SegoeUI" />
                        <Setter Property="FontSize" Value="12" />
                        <Setter Property="Foreground" Value="White" />
                        <Setter Property="HorizontalAlignment" Value="Center" />
                    </Style>
                </ApplicationBar.Resources>
                <Grid Margin="15,0,15,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90" />
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="270" />
                        <ColumnDefinition Width="90" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Vertical" Margin="0,14,0,5" Grid.Column="0">
                        <Button Margin="0,0,0,10" Style="{StaticResource AppBarLeftArrowIcon}"/>
                        <TextBlock Text="Opcion1" />
                    </StackPanel>
                <StackPanel Orientation="Vertical" Margin="0,14,0,5" Grid.Column="3">
                    <TextBox Margin="0,0,0,10" Name="tbNewTask"/>
                    <TextBlock Text="Nuevo Proyecto" />
                </StackPanel>
            <StackPanel Orientation="Vertical" Margin="0,14,0,5" Grid.Column="4">
                    <Button Margin="0,0,0,10"  Style="{StaticResource AppBarPlusIcon}" Click="Button_Click"/>
                        <TextBlock Text="Crear" />
                    </StackPanel>
                </Grid>
            </ApplicationBar>
        
        <local:AppSettingsPane x:Name="Settings" HorizontalAlignment="Right" Margin="0,0,-346,0"/>
    </Grid>
</UserControl>
